downloading_files
downloadButton(outputId, label="Download", class=NULL)
downloadHandler(filename, cntent, contentType=NA)
ui.R(downloading_files)
library(shiny)
shinyUI(pageWithSidebar(
headerPanel("Download Exmpale"),
sidebarPanel(
selectInput("dataset", "Choose a dataset: ", choices=c("rock", "pressure", "cars")),
downloadButton("downloadData", "Download")
),
mainPanel(
tableOutput("table")
)
))
server.R(downloading_files)
library(shiny)
shinyServer(function(input, output){
datasetInput<-reactive({
switch(input$dataset, "rock"=rock, "pressure"=pressure, "cars"=cars)
})
output$table<-renderTable({
datasetInput()
})
output$downloadData<-downloadHandler(
filename=function(){
paste(input$dataset, '.csv', sep='')
},
content=function(file){
write.csv(datasetInput(), file)
})
})